#include <iostream>

using namespace std;

class Solution {
public:
    int longestPalindrome(string s) {
        int map[52] = {0};
        for (char item : s) {
            if (item >= 'a' && item <= 'z') {
                map[item - 'a']++;
            } else if (item >= 'A' && item <= 'Z') {
                map[item - 'A' + 26]++;
            }
        }
        int len = 0;
        bool foot = false;
        for (int i = 0; i < 52; i++) {
            len += map[i] / 2 * 2;
            map[i] = map[i] % 2;
            if (map[i] == 1) {
                foot = true;
            }
        }
        if (foot) {
            len++;
        }
        return len;
    }
};